package com.lijiajia.cloud.common.security.access.expression.method;

import com.lijiajia.cloud.common.security.access.Authority;
import com.lijiajia.cloud.common.security.access.Role;
import com.lijiajia.cloud.common.security.access.expression.CustomSecurityExpressionRoot;
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
import org.springframework.security.core.Authentication;

/**
 * 扩展表达式root对象，包含额外的特定于方法的功能。
 *
 * @author lijiajia
 * @since 2019-05-30
 */
public class CustomMethodSecurityExpressionRoot extends CustomSecurityExpressionRoot implements
	MethodSecurityExpressionOperations {
	private Object filterObject;
	private Object returnObject;
	private Object target;

	public CustomMethodSecurityExpressionRoot(Authentication auth, Role role, Authority authority) {

		super(auth, role, authority);
	}


	public void setFilterObject(Object filterObject) {
		this.filterObject = filterObject;
	}

	public Object getFilterObject() {
		return filterObject;
	}

	public void setReturnObject(Object returnObject) {
		this.returnObject = returnObject;
	}

	public Object getReturnObject() {
		return returnObject;
	}

	/**
	 * Sets the "this" property for use in expressions. Typically this will be the "this"
	 * property of the {@code JoinPoint} representing the method invocation which is being
	 * protected.
	 *
	 * @param target the target object on which the method in is being invoked.
	 */
	void setThis(Object target) {
		this.target = target;
	}

	public Object getThis() {
		return target;
	}
}
